<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<div th:insert="/common.html"></div>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-3">
            <div id="tree"></div>
        </div>
        <div class="col-lg-9">
            <!-- addtabs导航栏-->
            <ul class="nav nav-tabs" id="myTab"></ul>
            <!-- addTabs内容容器 -->
            <div class="tab-content"></div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function getTree() {
        var tree = [];
        $.ajax({
            url:"/menu/getinfo",
            type:"get",
            dataType:"json",
            async:false,
            success:function (result){
                console.log(result)
                tree=result;
            },
            error:function (result){
                toastr.error("网络出现异常，请刷新");
                console.log(result);
            }
        })
        return tree;
    }

    // $('#tree').treeview('getCollapsed', nodeId);
    $("#tree").treeview({
        data: getTree(),
        showCheckbox: true,
        collapseIcon:"glyphicon glyphicon-minus",
        expandIcon:"glyphicon glyphicon-plus",
        onNodeSelected: function (event,data) {//data当前选择的节点
            if (data.nodes == undefined){
                $.addtabs.add({
                    title:data.text,
                    url:data.url,
                    id:data.id,
                    state:{
                        expanded:false,
                    },
                })
            }

        }
    });
</script>
<style>
    .iframeClass{
        height: 800px !important;
    }
</style>
</html>
